package com.zhongwang.business.module.basic.service;


import com.zhongwang.business.constant.Constant;
import com.zhongwang.business.module.basic.dao.OrgDao;
import com.zhongwang.business.module.basic.model.DictEnumModel;
import com.zhongwang.business.module.basic.model.OrgModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.zhongwang.business.constant.Constant.STATUS_NORMAL;


@Service
public class OrgBasicService {

    @Autowired
    private OrgDao orgDao;

    public  OrgModel findOrgByName(String name) {
        return orgDao.findByName(name);
    }



    public List<OrgModel> selectList(String name){
        return  orgDao.selectAll(name);
    }


    /**
     * 修改部门
     */
    public int updateOrg(OrgModel org) {
        org.setStatus(STATUS_NORMAL);
        return orgDao.update(org);
    }



    /**
     * 保存
     *
     * @param
     * @return
     */
    public int saveOrg(OrgModel org) {
        org.setStatus(STATUS_NORMAL);
        return orgDao.save(org);
    }


    /**
     * 删除
     */
    public int delOrg(Integer id) {
        return orgDao.updateStatusByIdWithRecursion(id, Constant.STATUS_DELETE);
    }


    /**
     * 校验 重复
     * @param groupName
     * @return
     */
   public  List<DictEnumModel> findDictByGroupName(String groupName){
        return orgDao.findByGroupName(groupName);
   }





}
